home *** CD-ROM | disk | FTP | other *** search
/ Czech Logic, Card & Gambling Games / Logické hry.iso / hry / Fish Fillets / script / share / level_start.lua < prev    next >
Encoding:
Text File  |  2005-07-16  |  2.2 KB  |  80 lines

  1. -- -----------------------------------------------------------------
  2. -- This script contains script_update() function,
  3. -- which is called every game cycle from the game.
  4. --
  5. -- NOTE: this script contains code structures to support
  6. -- original level design (e.g. afaze, X, Y, dir)
  7. -- -----------------------------------------------------------------
  8.  
  9. file_include("script/share/borejokes.lua")
  10. file_include("script/share/blackjokes.lua")
  11. file_include("script/share/bubles.lua")
  12. file_include("script/share/bordershout.lua")
  13.  
  14.  
  15. -- -----------------------------------------------------------------
  16. -- Init function
  17. -- -----------------------------------------------------------------
  18. function initModels()
  19.     -- Set starting values for all models
  20.     -- Run this function in you init
  21.     local models = getModelsTable()
  22.     for key, model in pairs(models) do
  23.         model.afaze = 0
  24.         model.X, model.Y = model:getLoc()
  25.         model.XStart, model.YStart = model:getLoc()
  26.         model.dir = dir_no
  27.         model.updateAnim = function(self)
  28.             self:setAnim("default", self.afaze)
  29.         end
  30.         model.anim = ""
  31.         resetanim(model)
  32.     end
  33.  
  34.     borderShoutLoad()
  35.     stdBoreJokeLoad()
  36.     stdBlackJokeLoad()
  37.     stdBublesLoad()
  38.     loadFonts()
  39. end
  40.  
  41.  
  42. -- -----------------------------------------------------------------
  43. -- Run functions
  44. -- -----------------------------------------------------------------
  45. local function updateModels()
  46.     -- update .X, .Y for all models
  47.     local models = getModelsTable()
  48.     for key, model in pairs(models) do
  49.         model.X, model.Y = model:getLoc()
  50.  
  51.         local action = model:getAction()
  52.         if "move_up" == action then
  53.             model.dir = dir_up
  54.         elseif "move_down" == action then
  55.             model.dir = dir_down
  56.         elseif "move_left" == action then
  57.             model.dir = dir_left
  58.         elseif "move_right" == action then
  59.             model.dir = dir_right
  60.         else
  61.             model.dir = dir_no
  62.         end
  63.     end
  64. end
  65.  
  66.  
  67. -- -----------------------------------------------------------------
  68. function script_update()
  69.     -- this function is called after every game cycle
  70.     animateUnits()
  71.     borderShout()
  72.  
  73.     updateModels()
  74.     prog_update()
  75.  
  76.     stdBubles()
  77.     stdBoreJoke()
  78.     stdBlackJoke()
  79. end
  80.